package com.otomotion.research.ants.databank;
import java.util.BitSet;

public class DirtLayer
{
    BitSet[] row;
    int x;
    int y;
    DirtLayer(int x, int y)
    {
        this.x=x;
        this.y=y;
        row = new BitSet[x];
        for (int i = 0; i<x; i++)
        {
            row[i]=new BitSet(y);
            row[i].set(0, y-1, false);
        }
    }

    public boolean isDirt(int x, int y)
    {
        return row[x].get(y);
    }

    public boolean setDirt(int x, int y)
    {
        row[x].set(y);
        return true;
    }
    public boolean clearDirt(int x, int y)
    {
        row[x].clear(y);
        return true;
    }
    public void dirtify()
    {
        for (int i = 0; i<row.length; i++)
        {
            row[i].set(0, y, true);
        }
    }
}
